package com.gongpingjialoan.activity.car;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.gongpingjialoan.R;
import com.gongpingjialoan.activity.main.BaseActivity;
import com.gongpingjialoan.activity.main.MainActivity;
import com.gongpingjialoan.adapter.CarSourceListAdapter;
import com.gongpingjialoan.adapter.LooperAdapter;
import com.gongpingjialoan.api.API;
import com.gongpingjialoan.bean.BannerBean;
import com.gongpingjialoan.bean.CarSource;
import com.gongpingjialoan.bean.Monitor;
import com.gongpingjialoan.bean.VipBuycarBean;
import com.gongpingjialoan.data.CityData;
import com.gongpingjialoan.global.GPJApplication;
import com.gongpingjialoan.network.NetDataJson;
import com.gongpingjialoan.network.NetDataJson.OnNetDataJsonListener;
import com.gongpingjialoan.utility.DhUtil;
import com.gongpingjialoan.utility.StepMonitor;
import com.gongpingjialoan.utility.UserLocation;
import com.gongpingjialoan.utility.Utils;
import com.gongpingjialoan.widget.LoadingDialog;
import com.gongpingjialoan.widget.RegisterVipFilterDialog;
import com.gongpingjialoan.widget.autoviewpagers.ColorPointHintView;
import com.gongpingjialoan.widget.autoviewpagers.RollPagerView;
import com.google.gson.Gson;
import com.handmark.pulltorefresh.library.PullToRefreshBase;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/3/22.
 */
public class VipRecomendCarActivity extends BaseActivity implements View.OnClickListener, AdapterView.OnItemClickListener, OnNetDataJsonListener, PullToRefreshBase.OnRefreshListener<ListView>, PullToRefreshBase.OnLastItemVisibleListener {

    private VipBuycarBean mVipBuycarBean;

    private NetDataJson mNetDataJson, registerNetDataJson;

//    private PullToRefreshListView pullToRefreshListView;

    private ListView listView;

    private CarSourceListAdapter mVipCarListAdapter;

    private ImageView nocarImageView;

    private List<CarSource> carSourceDataList;

    private View footView;

    private LoadingDialog loadingDialog;

    private boolean isShowDialog = false;

    private String city, price, intent, function, phone, others, time, type, brand_model, color, age, mile_l, mile_h, useloan;

    private TextView moreTextView;

    private ImageView registerImageView;

    private boolean isAddFootView = false;

    private View rightView, headView;

    private RollPagerView mRollPagerView, mRollPagerView1;

    private boolean isShowBanner = false;

    private LooperAdapter mLooperAdapter, mLooperAdapter1;

    private LinearLayout rollLinearLayout, rollLinearLayout1;

    private TextView list_title;

    private int aHeight;

    CityData mCityData;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        isSendData = true;
        action = "vipBuy_list";
        super.onCreate(savedInstanceState);
        setContentView(R.layout.vip_recomend_car_layout);
        EventBus.getDefault().register(this);
        setTitle("买车推荐");
        aHeight = DhUtil.dip2px(this, 120);
        mVipBuycarBean = getIntent().getParcelableExtra("mVipBuycarBean");
        initView();
        getFromData();
        refreshData();
    }


    public void initBanner() {
        BannerBean bannerBean = GPJApplication.getInstance().mBannerBean;
        if (!isShowBanner && bannerBean != null && "success".equals(bannerBean.getStatus())) {
            isShowBanner = true;
            List<BannerBean.DataEntity.EvalEntity> dataEntities = bannerBean.getData().getMarket();
            if (dataEntities != null && dataEntities.size() > 0) {
                Glide.with(this).load(dataEntities.get(0).getImg()).into(new SimpleTarget<GlideDrawable>() {
                    @Override
                    public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                        int width = getResources().getDisplayMetrics().widthPixels;
                        int height = resource.getIntrinsicHeight() * width / resource.getIntrinsicWidth();
                        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width, height);
                        rollLinearLayout.addView(mRollPagerView, lp);
                        rollLinearLayout1.addView(mRollPagerView1, lp);
                    }
                });
                mRollPagerView.setVisibility(View.VISIBLE);
                mRollPagerView1.setVisibility(View.VISIBLE);
                mLooperAdapter = new LooperAdapter(mRollPagerView, dataEntities, this, getSupportFragmentManager(), false);
                mLooperAdapter1 = new LooperAdapter(mRollPagerView1, dataEntities, this, getSupportFragmentManager(), false);
                mLooperAdapter.setIsBaoxian(true);
                mLooperAdapter1.setIsBaoxian(true);
                mRollPagerView.setAdapter(mLooperAdapter);
                mRollPagerView1.setAdapter(mLooperAdapter1);
            }
        } else {
            getNotification();
        }
    }


    private void initView() {
        mCityData = ((GPJApplication) getApplication()).getCityData();
        loadingDialog = new LoadingDialog(this);
        moreTextView = (TextView) findViewById(R.id.more_car);
        rollLinearLayout1 = (LinearLayout) findViewById(R.id.rollmain1);
        headView = LayoutInflater.from(this).inflate(R.layout.vip_header_view, null);
        list_title = (TextView) headView.findViewById(R.id.list_title);

        headView.findViewById(R.id.success).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
            }
        });
        rollLinearLayout = (LinearLayout) headView.findViewById(R.id.rollmain);
        mRollPagerView = new RollPagerView(this);
        mRollPagerView.setHintView(new ColorPointHintView(this, Color.WHITE, Color.GRAY));
        mRollPagerView.setPlayDelay(3000);
        mRollPagerView.setVisibility(View.GONE);

        mRollPagerView1 = new RollPagerView(this);
        mRollPagerView1.setHintView(new ColorPointHintView(this, Color.WHITE, Color.GRAY));
        mRollPagerView1.setPlayDelay(3000);


        initBanner();

        registerImageView = (ImageView) findViewById(R.id.right_img);
        registerImageView.setImageResource(R.drawable.register_buy_icon);
        registerImageView.setVisibility(View.GONE);
        rightView = findViewById(R.id.right_layout);
        rightView.setVisibility(View.GONE);

        footView = LayoutInflater.from(this).inflate(R.layout.vip_car_footview, null);
        moreTextView = (TextView) footView.findViewById(R.id.more_car);
        moreTextView.setOnClickListener(this);
        rightView.setOnClickListener(this);
        nocarImageView = (ImageView) headView.findViewById(R.id.no_car_id);
//        pullToRefreshListView = (PullToRefreshListView) findViewById(R.id.listview);
//        pullToRefreshListView.setScrollingWhileRefreshingEnabled(false);
//        pullToRefreshListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
//        pullToRefreshListView.setOnRefreshListener(this);
        //   pullToRefreshListView.setOnLastItemVisibleListener(this);
        carSourceDataList = new ArrayList<>();
        mVipCarListAdapter = new CarSourceListAdapter(this);


        // listView = pullToRefreshListView.getRefreshableView();
        listView = (ListView) findViewById(R.id.list_view);
//        listView.addFooterView(footView);
        listView.addHeaderView(headView);
        listView.setAdapter(mVipCarListAdapter);
        listView.setOnItemClickListener(this);
//        listView.removeFooterView(footView);
//        listView.setOnScrollListener(new AbsListView.OnScrollListener() {
//            @Override
//            public void onScrollStateChanged(AbsListView view, int scrollState) {
//
//            }
//
//            @Override
//            public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
//                if (!isShowDialog) {
//                    if (getScrollY() > getResources().getDisplayMetrics().heightPixels) {
//                        isShowDialog = true;
//                        RegisterVipFilterDialog registerVipFilterDialog = new RegisterVipFilterDialog(VipRecomendCarActivity.this);
//                        registerVipFilterDialog.show();
//                    }
//                }
//                if (getScrollY() >= aHeight) {
//                    if (rollLinearLayout1.getVisibility() == View.INVISIBLE) {
//                        rollLinearLayout1.setVisibility(View.VISIBLE);
//                    }
//                } else if (getScrollY() < aHeight) {
//                    if (rollLinearLayout1.getVisibility() == View.VISIBLE) {
//                        rollLinearLayout1.setVisibility(View.INVISIBLE);
//                    }
//                }
//
//                int height = getScrollY();
//                //记录最高的滑动距离
//                if (height >= scrollHeight) {
//                    scrollHeight = height;
//                    roll_pages = DhUtil.getRollPages(GPJApplication.getInstance(), scrollHeight);
//                }
//            }
//        });
        mVipCarListAdapter.notifyDataSetChanged();
    }


    public int getScrollY() {
        if (listView.getChildCount() == 0) return 0;
        View c = listView.getChildAt(0);
        if (c == null) {
            return 0;
        }
        int firstVisiblePosition = listView.getFirstVisiblePosition();
        int top = c.getTop();

        return -top + firstVisiblePosition * c.getHeight();
    }

    private void getFromData() {
        useloan = mVipBuycarBean.getUseloan();
        type = mVipBuycarBean.getType();
        city = mVipBuycarBean.getCity();
        if (TextUtils.isEmpty(city)) {
            city = MainActivity.main.currentCity;
            mVipBuycarBean.setCity(city);
        }
        price = mVipBuycarBean.getPrice();
        time = mVipBuycarBean.getTimes();
        intent = mVipBuycarBean.getItent();
        function = mVipBuycarBean.getFunction();
        phone = mVipBuycarBean.getPhone();
        others = mVipBuycarBean.getOthers();

        brand_model = mVipBuycarBean.getBrand_models();
        color = mVipBuycarBean.getColors();
        age = mVipBuycarBean.getAge();
        if ("车龄不限".equals(age)) {
            age = "";
        }
        try {
            String[] mile = mVipBuycarBean.getMile().split("-");
            mile_l = mile[0];
            mile_h = mile[1];
        } catch (Exception e) {

        }
    }


    private void refreshData() {
        nocarImageView.setVisibility(View.GONE);
        list_title.setVisibility(View.VISIBLE);
        getData();
    }

    private void getData() {
        if (mNetDataJson == null) {
            mNetDataJson = new NetDataJson(this);
        }
        mNetDataJson.clearMap();
        mNetDataJson.setUrl(API.carListSearch);

        mNetDataJson.addParam("city", mCityData.mCurrentCity);
//        mNetDataJson.addParam("province", provice);
        mNetDataJson.addParam("page", 1);
//        mNetDataJson.addParam("front_cover", front_cover);
//        mNetDataJson.addParam("is_cut_price", isCut);
//        mNetDataJson.addParam("is_certify", is_certify);

        if (UserLocation.getInstance().isIslocation()) {
            mNetDataJson.addParam("lat", UserLocation.getInstance().getLatitude());
            mNetDataJson.addParam("lng", UserLocation.getInstance().getLongitude());
        }
        String brand = "";
        String model = "";
        if (!TextUtils.isEmpty(mVipBuycarBean.getBrand_models()) && mVipBuycarBean.getBrand_models().contains(",")) {
            brand = mVipBuycarBean.getBrand_models().split(",")[0];
            model = mVipBuycarBean.getBrand_models().split(",")[1];
        }


        String mile = mVipBuycarBean.getMile();
        if (!TextUtils.isEmpty(brand))
            mNetDataJson.addParam("brand", brand);
        if (!TextUtils.isEmpty(mile))
            mNetDataJson.addParam("mile", mile);
        if (!TextUtils.isEmpty(model))
            mNetDataJson.addParam("model", model);
        if (!TextUtils.isEmpty(price))
            mNetDataJson.addParam("approx_price", price);
        if (!TextUtils.isEmpty(age))
            mNetDataJson.addParam("year", Utils.getVipCarAge(Integer.parseInt(age)));
//        if (!TextUtils.isEmpty(sort))
//            mNetDataJson.addParam("sort", sort);
//        if (!TextUtils.isEmpty(color))
//            mNetDataJson.addParam("colors", color);
//        if (!TextUtils.isEmpty(vehicle_model))
//            mNetDataJson.addParam("vehicle_model", vehicle_model);
//        if (!TextUtils.isEmpty(car_type))
//            mNetDataJson.addParam("car_type", car_type);
//        if (!TextUtils.isEmpty(car_attribute))
//            mNetDataJson.addParam("car_attribute", car_attribute);
//        if (!TextUtils.isEmpty(car_volume))
//            mNetDataJson.addParam("car_volume", car_volume);
//        if (!TextUtils.isEmpty(control))
//            mNetDataJson.addParam("control", control);
//        if (!TextUtils.isEmpty(domain))
//            mNetDataJson.addParam("domain", domain);
        mNetDataJson.request("get");


//        mNetDataJson.addParam("useloan", useloan);
//        Log.d("useloan", "useloan:--------------" + useloan);
//        if ("specific".equals(type)) {
//            mNetDataJson.addParam("phone", phone);
//            mNetDataJson.addParam("price", price);
//            mNetDataJson.addParam("expect_period", time);
//            mNetDataJson.addParam("city", city);
//            mNetDataJson.addParam("other_recommend", others);
//            mNetDataJson.addParam("brand_models", brand_model);
//            mNetDataJson.addParam("colors", color);
//            mNetDataJson.addParam("age_h", age);
//            mNetDataJson.addParam("mile_l", mile_l);
//            mNetDataJson.addParam("mile_h", mile_h);
//
//            mNetDataJson.postType = type;
//        } else {
//            mNetDataJson.addParam("phone", phone);
//            mNetDataJson.addParam("price", price);
//            mNetDataJson.addParam("expect_period", time);
//            mNetDataJson.addParam("uses", function);
//            mNetDataJson.addParam("city", city);
//            mNetDataJson.addParam("vehicle_model", intent);
//            mNetDataJson.addParam("other_recommend", others);
//            mNetDataJson.postType = type;
//        }
////        mNetDataJson.addParam("demand_type" , type);
//        mNetDataJson.request("get");
        loadingDialog.show();
    }


    @Override
    public void onDataJsonError(String errorMessage) {
        loadingDialog.dismiss();
        Toast.makeText(this, errorMessage, Toast.LENGTH_SHORT).show();
        // pullToRefreshListView.onRefreshComplete();
    }

    @Override
    public void onDataJsonUpdate(JSONObject json) {
        JSONArray jsonArray = null;
        listView.setVisibility(View.VISIBLE);
        loadingDialog.dismiss();

        try {
            jsonArray = json.getJSONArray("car_list");
            if (0 == jsonArray.length()) {
                //Toast.makeText(this, "未找到相应数据", Toast.LENGTH_SHORT).show();
                nocarImageView.setVisibility(View.VISIBLE);
                list_title.setVisibility(View.GONE);
                // pullToRefreshListView.onRefreshComplete();
                return;
            }
//            changeColor(json);
            getDataFromJsonArray(jsonArray);


        } catch (Exception e) {
            Toast.makeText(this, "未找到相应数据", Toast.LENGTH_SHORT).show();
            //  pullToRefreshListView.onRefreshComplete();
            return;
        }
        updateListView();
    }


    private void changeColor(JSONObject json) throws Exception {
        if (!isAddFootView) {
            listView.addFooterView(footView);
            isAddFootView = true;
        }
        int allnumber = json.getInt("car_num");
        String number;
        if (allnumber > 1000) {
            number = "1000+";
        } else {
            number = allnumber + "";
        }
        String str = "还有" + number + "辆车源符合您的条件,点击查看更多";
        moreTextView.setText(Utils.changeColor(this, str, 2, 2 + number.length(), R.color.like_car_color));
    }


    public void updateListView() {
        if (carSourceDataList.size() != 0) {
            mVipCarListAdapter.setData(carSourceDataList);
            //  pullToRefreshListView.onRefreshComplete();
            nocarImageView.setVisibility(View.GONE);
            list_title.setVisibility(View.VISIBLE);
        } else {
            nocarImageView.setVisibility(View.VISIBLE);
            list_title.setVisibility(View.GONE);
        }
    }

    @Override
    public void onLastItemVisible() {
    }


    boolean isFristLoading = true;

    @Override
    public void onRefresh(PullToRefreshBase<ListView> refreshView) {
        if (!isFristLoading) {
            String label =
                    "更新时间:" + DateUtils.formatDateTime(this, System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME
                            | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL);
            refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(label);
        }
        isFristLoading = false;
        refreshData();
    }

    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
//        if (position == 0) return;
//        Intent intent = new Intent();
//        intent.setClass(this, CarBuyDetailActivity.class);
//        CarSource carSource = (CarSource) view.getTag(R.id.tag_second);
//        intent.putExtra("typevalue", String.valueOf(carSource.mId));
//        intent.putExtra("type", "viprecomend");
//        intent.putExtra("from", "vip");
//        startActivity(intent);
    }


    private void getDataFromJsonArray(JSONArray jsonArray) throws JSONException {
        // Log.e("getDataFromJsonArray", "getDataFromJsonArray");
        for (int i = 0; i < jsonArray.length(); i++) {
            CarSource carSrc = new CarSource();
            JSONObject object = jsonArray.getJSONObject(i);
            carSrc.mCity = mCityData.mCurrentCity;
//            if (isMoreCity() || isSuggest) {
//                carSrc.newCity = object.getString("city");
//            }
            carSrc.distance = object.getString("distance");
            carSrc.mTitle = object.getString("title");
            carSrc.mYear = object.getString("year");
            carSrc.mMile = object.getString("mile").equals("None") ? "" : object.getString("mile");
            carSrc.mPrice = Double.valueOf(object.getString("price"));
            carSrc.mId = object.getInt("id");
            carSrc.isViewed = object.getBoolean("viewed");
            carSrc.mThumbnail = object.getString("thumbnail");
            carSrc.mTime = object.getString("time");
            carSrc.hasmodel = object.getString("has_model_detail");
            carSrc.is_certify = object.getBoolean("is_certify");
            carSrc.pub_timestamp = object.getString("pub_timestamp");
            // carSrc.mRecommend = object.getString("recommend");
            carSrc.mSourceType = object.getString("source_type");
            carSrc.mGpjIndex = object.getDouble("gpj_index");
            carSrc.mQsTags = object.getString("qs_tags");
            carSrc.mSource = object.getString("domain");
            carSrc.dealer_category = object.getString("dealer_category");
            carSrc.pubTime = object.getString("pub_time");
            carSrc.brand_zh = object.getString("brand_slug_zh");
            carSrc.model_zh = object.getString("model_slug_zh");
            carSrc.model_detail_zh = object.getString("model_detail_slug_zh");
            carSrc.isactive = object.getBoolean("seller_active");
            carSrc.origin_price = object.getString("origin_price");
            carSrc.lowest_price = object.getString("lowest_price");
            carSrc.last_price = object.getString("last_price");

            carSrc.cs_clean = object.getBoolean("cs_clean");
            carSrc.setBrand(object.getString("brand_slug"));
            carSrc.setModel(object.getString("model_slug"));

            carSrc.mUrl = carSrc.mThumbnail;
            carSourceDataList.add(carSrc);
        }
    }

    @Override
    public void onClick(View v) {
        if (v == rightView) {
            isShowDialog = true;
            StepMonitor.getInstance().addMonitor(new Monitor("click", "buy_market_vipBuy_list_subscribe", System.currentTimeMillis(), roll_pages));
            RegisterVipFilterDialog registerVipFilterDialog = new RegisterVipFilterDialog(this);
            registerVipFilterDialog.show();
        } else if (v == moreTextView) {
            Intent intent = new Intent(this, CarListActivity.class);
            intent.putExtra("type", "vip_no_domain");
            intent.putExtra("mVipBuycarBean", mVipBuycarBean);
            startActivity(intent);
        }
    }

    private String getShowVehicleModel(String vm) {
        if (TextUtils.isEmpty(vm)) return "";
        String[] datas = vm.split(",");
        int size = datas.length;
        int length = CarListFragment.show_carModel.length;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < length; j++) {
                if (datas[i].equals(CarListFragment.need_carModel[j])) {
                    sb.append(CarListFragment.show_carModel[j]).append(",");
                }
            }
        }
        return sb.toString();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (registerNetDataJson != null) {
            registerNetDataJson.cancelTask();
            registerNetDataJson = null;
        }
        if (mNetDataJson != null) {
            mNetDataJson.cancelTask();
            mNetDataJson = null;
        }
        StepMonitor.getInstance().addMonitor(new Monitor("scroll", action, System.currentTimeMillis(), roll_pages));
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void refresh(Object o) {
        if ("notification".equals(o.toString())) {
            initBanner();
        }
    }

    //订阅回调
    public void register(String frequency, String time) {
        String start_time = "";
        String end_time = "";
        if ("od".equals(frequency)) {
            String[] times = time.split("-");
            start_time = times[0] + ":00";
            end_time = times[1] + ":00";
        }
        if (registerNetDataJson == null) {
            registerNetDataJson = new NetDataJson(new OnNetDataJsonListener() {
                @Override
                public void onDataJsonError(String errorMessage) {
                    Toast.makeText(VipRecomendCarActivity.this, errorMessage, Toast.LENGTH_SHORT).show();
                    loadingDialog.hide();
                }

                @Override
                public void onDataJsonUpdate(JSONObject json) {
                    loadingDialog.hide();
                    EventBus.getDefault().post("register_vip");
                    Toast.makeText(VipRecomendCarActivity.this, "订阅成功!", Toast.LENGTH_SHORT).show();
                }
            });
        }
        registerNetDataJson.setUrl(API.register_filter_push);
        registerNetDataJson.clearMap();
        registerNetDataJson.addParam("frequency", frequency);
        registerNetDataJson.addParam("vip_buy_type", mVipBuycarBean.getType());
        if ("od".equals(frequency)) {
            registerNetDataJson.addParam("start_time", start_time);
            registerNetDataJson.addParam("end_time", end_time);
        }
        registerNetDataJson.request("post");
        loadingDialog.show();

    }


//    private void getTmpData() {
//        NetDataJson netDataJson = new NetDataJson(new OnNetDataJsonListener() {
//            String url = "";
//
//            @Override
//            public void onDataJsonError(String errorMessage) {
//                url = (String) SharedPreferencesUtil.get(VipRecomendCarActivity.this, "VIP_BUY_EMPTY_PLACEHOLDER", "");
//                ImageLoad.LoadImage(nocarImageView, url, R.drawable.vip_nodata, R.drawable.vip_nodata, VipRecomendCarActivity.this);
//            }
//
//            @Override
//            public void onDataJsonUpdate(JSONObject json) {
//                try {
//                    JSONObject jsonObject = json.getJSONObject("data");
//                    url = jsonObject.getString("VIP_BUY_EMPTY_PLACEHOLDER");
//                    ImageLoad.LoadImage(nocarImageView, url, R.drawable.vip_nodata, R.drawable.vip_nodata, VipRecomendCarActivity.this);
//                    SharedPreferencesUtil.put(VipRecomendCarActivity.this, "VIP_BUY_EMPTY_PLACEHOLDER", url);
//                } catch (JSONException e) {
//                    url = (String) SharedPreferencesUtil.get(VipRecomendCarActivity.this, "VIP_BUY_EMPTY_PLACEHOLDER", "");
//                    ImageLoad.LoadImage(nocarImageView, url, R.drawable.vip_nodata, R.drawable.vip_nodata, VipRecomendCarActivity.this);
//                }
//            }
//        });
//        netDataJson.setUrl(API.get_tmp_data);
//        netDataJson.request("get");
//    }


    public void getNotification() {
        NetDataJson netNetDataJson = new NetDataJson(new NetDataJson.OnStringListener() {
            @Override
            public void onDataJsonError(String errorMessage) {

            }

            @Override
            public void onDataJsonUpdate(String json) {
                Gson gson = new Gson();
                BannerBean mBannerBean = gson.fromJson(json, BannerBean.class);
                GPJApplication.getInstance().mBannerBean = mBannerBean;
                if ("success".equals(mBannerBean.getStatus())) {
                    initBanner();
                }
            }
        }, 1);
        netNetDataJson.setUrl(API.getBanner);
        netNetDataJson.request("get");
    }

}
